function process(data){
    console.log(data);
}

//------------------------------------------------------------------------------
// Start of text fetch/send code for googledocs
//------------------------------------------------------------------------------

//Get the raw text from the google document
$(document).ready(function(){
	chrome.extension.sendRequest({encrypted_content: getRawTextOfDoc()}, 
		function(response) {
	});
});

/**
 * Gets the raw text of a google document from html using jQuery.
 * 
 * @see:  http://api.jquery.com/jQuery.get/
 * @note: This function needs the document to be ready
 */
function getRawTextOfDoc(){
	
	//This gets the raw text of any html and text between all matching span elements
	var text = $('div.kix-lineview-content').text();
	
	//We could now encrypt or decrypt text in another function
	return text;
}

/**
 * Sets the text of a google document.
 *
 */
function setRawTextOfDoc(text){

   //Give text a default value if undefined
   text = typeof text !== 'undefined' ? text: ' ';

	/*We can then set the text of a google doc like so,
	  note though that this assumes at least one such element exists in
	  the page (if not need to try another element).
    */
	$('span.kix-lineview-text-block:first').html(text);
}

